/*
* @Author: dengjiayao
* @Date:   2017-08-11 16:43:46
* @Last Modified by:   dengjiayao
* @Last Modified time: 2017-08-11 16:58:50
*/

import { showMsg, importExpert } from '../../vuex/action'

export default {
  name: 'export-import',
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xImport: importExpert
    }
  },
  methods: {
    importFile() {
      let el = this.$els.file
      if (el.files.length) {
        let file = el.files[0]
        let formData = new FormData()
        formData.append('excelFile', file)
        this.xImport(formData)
          .then(() => {
            window.location.reload()
          })
          .catch((res) => {
            this.xShowMsg({
              type: 'danger',
              content: res.error_msg
            })
          })
      }
    }
  }
}